import React, {Component} from 'react'

class Top extends Component{

    constructor(props){
        super(props);
        this.state={
            inputValue:'aa'
        }
        this.handleInputChange = this.handleInputChange.bind(this);
        this.handleBtnClick = this.handleBtnClick.bind(this);
    }
    render(){
        return (
            <div>
                <input value={this.state.inputValue} onChange={this.handleInputChange}/>
                <button onClick={this.handleBtnClick}>提交</button>
            </div>
        )
    }
    handleInputChange(e){
        const value = e.target.value;
        this.setState( () =>({
            inputValue:value
        }))
    }
    handleBtnClick(){
        this.setState( () => ({
            inputValue:''
        }))
    }
}
export default Top;